﻿// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");

// 责任链模式

// 请假流程
using ChainOfResponsibilityPattern;

ApplyContext context = new ApplyContext()
{
    Name = "张三",
    Id = 1,
    Hours = 13,
    Description = "家中有事"
};

// 菜鸟开发
/*if (context.Hours <= 8)
{
    PM pM = new PM() { Name = "李四" };
    pM.Audit(context);
}
else if (context.Hours <= 16)
{
    Manager manager = new Manager() { Name = "王五" };
    manager.Audit(context);

    Console.WriteLine("....");
}*/

// 中级开发
/*PM pM = new PM() { Name = "李四" };
pM.Audit(context);
if (!context.AuditResult)
{
    Manager manager = new Manager() { Name = "王五" };
    manager.Audit(context);
    if (!context.AuditResult)
    {
        Chief chief = new Chief() { Name = "赵六" };
        chief.Audit(context);
    }
}
*/
// 高级开发 问题：流程定死了，如果流程需要改变需要修改代码了
//PM pM = new PM() { Name = "李四" };
//pM.Audit(context);

// 经验丰富的高级开发 ,不仅能够控制流程，而且还可以增减调换顺序
PM pM = new PM() { Name = "李四",AuditHours=8 };
Manager manager = new Manager() { Name = "王五",AuditHours=32 };
Chief chief = new Chief() { Name = "赵六",AuditHours=16 };
CEO cEO = new CEO() { Name = "田七",AuditHours=64 };

pM.SetNext(manager);
//manager.SetNext(chief);
//chief.SetNext(cEO);
pM.SetNext(chief);
chief.SetNext(manager);
manager.SetNext(cEO);
// manager.Audit(context);
pM.Audit(context);